package 力扣日常刷题.木22一月.第15天0127;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @author 帅小伙
 * @date 2022/1/27
 * @description
 */
public class Demo09JZ09用两个栈实现队列 {


    class CQueue {

        public Queue<Integer> stack1 ;
        public Queue<Integer> stack2 ;

        public CQueue() {
            stack1 = new ArrayDeque<>();
            stack2 = new ArrayDeque<>();
        }

        public void appendTail(int value) {
            stack1.add(value);
        }

        public int deleteHead() {
            if(stack2.size() == 0) {
                if(stack1.size() == 0) return -1;
                else{
                    while(stack1.size() > 0) stack2.add(stack1.poll());
                }
            }
            return stack2.poll();
        }
    }

}
